package eventManager;

import java.util.ArrayList;

import utilities.Key;

/**
 * Events used by the game to shuffle around data, trigger changes in gameState, etc.
 * 
 * There are three types of events:
 * 1) System Events:  Low level events dealing with program execution, etc.
 * 2) App Events:  Mid-level events that move around data, change gameState, etc. behind the scenes
 * 3) Game Events:  In-game events are viewable to the player/AI.
 * @author rmeyers
 *
 */
//Specifies data that all events must use.  Inherited by all events.
public class AppEvent implements IEventData {

	private String eventName;
	private float timeStamp;	
	private Key target;
	private Key sender;
	private Object[] eventObjects;// = new ArrayList<Object>();
	
	//USED FOR BROADCASTS TO ALL LISTENERS
	public AppEvent(String eventName) 
	{
		this.timeStamp = System.currentTimeMillis();
		this.eventName = eventName;
		this.eventObjects = new Object[0];
		this.target = null; //defaults to broadcast mode (see EventManager class)
		this.sender = null;
	}
	
	public AppEvent(String eventName, Object[] objList) {
		this.timeStamp = System.currentTimeMillis();
		this.eventName = eventName;
		this.eventObjects = objList;
		this.target = null; //defaults to broadcast mode (see EventManager class)
		this.sender = null;
	}
	
	
	//Alternative constructor, specifies a target for the event
	//USED TO SEND MESSAGE/DATA TO A SPECIFIC LOCATION
	public AppEvent(String eventName, Key target) {
		this.timeStamp = System.currentTimeMillis();
		this.eventName = eventName;
		this.eventObjects = new Object[0];
		this.target = target;
		this.sender = null;
	}
	
	public AppEvent(String eventName, Key target, Object[] objList) {
		this.timeStamp = System.currentTimeMillis();
		this.eventName = eventName;
		this.eventObjects = objList;
		this.target = target;
		this.sender = null;
	}
	
	
	//Alternative constructor, specifies a target for the event and a callback object
	//USED FOR DATA REQUESTS
	public AppEvent(String eventName, Key target, Key sender) {
		this.eventName = eventName;
		this.timeStamp = System.currentTimeMillis();
		this.eventObjects = new Object[0];
		this.target = target;
		this.sender = sender;
	}
	
	public AppEvent(String eventName, Key target, Key sender, Object[] objList) {
		this.eventName = eventName;
		this.timeStamp = System.currentTimeMillis();
		this.eventObjects = objList;
		this.target = target;
		this.sender = sender;
	}


	public String getEventName() {				
		return eventName;
	}
	
	public float getTimeStamp() {
		return timeStamp;
	}
	
	public Key getTarget() {
		return this.target;		
	}
	
	public Key getSender() {
		return this.sender;
	}
	
	public Object[] getEventObjects() {				
		return this.eventObjects;
	}	

}
